package game.http;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class MainClass {
	
	public static void main(String[] args) {
		try {
			String destination = "http://www.baidu.com";
			// 定义URL对象
			URL url = new URL(destination);
			// 打开连接，并强制转换为HttpURLConnection
			HttpURLConnection conn = (HttpURLConnection)url.openConnection();
			conn.connect();
			
			BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
			StringBuffer sBuffer = new StringBuffer();
			String line = "";
			while((line = reader.readLine()) != null) {
				sBuffer.append(line).append("\r\n");
			}
			
			System.out.println("http response code ===> " + conn.getResponseCode());
			System.out.println("http response ===> " + sBuffer);
			conn.disconnect();
		}catch (Exception e) {
			// TODO: handle exception
		}
	}

}
